package StringStudy;

import java.util.Scanner;

/**
 * 检验一个字符串是否合法的Email
 * 标准：
 * 1. 检测是否包含@
 * 2. @前边要有字符
 * 3. @后边要有字符串
 * 4. @后边要包含点
 * 全部满足，提示用户“Email合法”
 * 否则：提示用户"非法Email"
 */
public class StringExample {
    public static void main(String[] args) {
////        String email;
////        Scanner scanner = new Scanner(System.in);
////        email = scanner.next();
////        boolean flag=false;
////        //1.判断@
////        if(email.indexOf('@')==-1)
////        {
////            System.out.println("Email非法,缺少@");
////            return;
////        }
//      //  System.out.println("email.indexOf('@') = " + email.indexOf('@'));
////        for (int i = 0; i < email.length(); i++) {
////            if(email.charAt(i)=='@')
////            {
////                flag=true;
////                break;
////            }
////        }
////        if(!flag)
////        {
////            System.out.println("Email非法");
////            return;
////        }
//
////        String email="abcde";
////        String substring = email.substring(0,);
////        System.out.println("substring = " + substring);
//
////        System.out.println("email.substring(0,email.indexOf(\"@\")+1) = " + email.substring(0, email.indexOf("@")));
//        if(email.substring(0, email.indexOf("@")).length()==0)
//        {
//            System.out.println("email非法，@前边的字符呢？");
//            return;
//        }
////7
//        if(email.substring(email.indexOf("@")+1,email.length()).length()==0)
//        {
//            System.out.println("email非法，@后边的字符呢？");
//            return;
//        }
//        email.substring(email.indexOf("@")+1,email.length()).indexOf('.')==-1;
//        email.trim()


    }
}
